package q154_findMin;

public class Solution {
    /*
    旋转排序的最小值，参考二分标准模版来思考
    但是有数组中有重复值 所以当mid和high的值相等的时候
    要多一个--high;操作
     */
    public int findMin(int[] nums) {
        int low = 0, high = nums.length - 1;
        while (low < high) {
            int mid = low + ((high - low) >> 1);
            if (nums[mid] > nums[high]) {
                low = mid + 1;
            } else if (nums[mid] < nums[high]) {
                high = mid;
            } else {
                --high;
            }
        }

        return nums[low];
    }
}
